package pl.edu.pw.perg.compinfodb.entities.attribute;

import java.math.BigDecimal;

import pl.edu.pw.perg.compinfodb.entities.IPhysicalElement;
import pl.edu.pw.perg.compinfodb.entities.field.Field;

public class NumericAttribute extends Attribute {

	/**
	 *
	 */
	private static final long serialVersionUID = -5980968861283807907L;

	private BigDecimal numericValue;

	public NumericAttribute(Number number, Field field, IPhysicalElement e) {
		super(field, e);
		numericValue = BigDecimal.valueOf(number.doubleValue());
	}

	public NumericAttribute(Field field, IPhysicalElement e) {
		super(field, e);
	}
	public NumericAttribute() {

	}

	public BigDecimal getNumericValue() {
		return numericValue;
	}

	public void setNumericValue(BigDecimal numericValue) {
		this.numericValue = numericValue;
	}

	@Override
	public String toString() {
		return numericValue.toString();
	}

	public boolean matchesFilter(IAttribute a) {
		if(a == null)
			return true;
		String filter = a.getTextValue();
		if(numericValue.toPlainString().contains(filter))
			return true;
		return false;
	}


}
